﻿@model IEnumerable<CmsMediaContent>
           
@{
    var totalItems = (int) ViewBag.TotalItems;
    var mediaId = (int) ViewBag.FolderId;
    var keyword = (string) ViewBag.Keyword;
    var mediaTypes = (string) ViewBag.MediaTypes;
    ResFile = "cms_Media";
}


@functions {
    private string GetCurrent(int i)
    {
        return i == 1 ? "b-current" : "";
    }
}

@Html.Hidden("hiddenMediaTypes",mediaTypes)
<div id="js-mediapicker-content" class="js-pager-container">
@if (Model != null && Model.Any())
{
    <ul>
        @foreach (var mediaContent in Model)
        {
            <li>
                <a href="#" class="js-mediapicker-content-item" data-content-id="@mediaContent.MainFile.Id" data-linked-file="@mediaContent.MainFile.LinkedFileName">
                    @mediaContent.MediaContentName 
                </a>
            </li>
        }
    </ul>
}
else
{
    <span>@_("Currently there are no files")</span>
}
     
    <div class="pager g-clear">
    @for (int i = 1; i < Math.Ceiling((double)totalItems / 5) + 1; i++)
    {
        <a href="@(Url.Action("Load", "CmsMediaPicker"))?page=@i&size=5" class="pager__item js-cms-pager-link js-cms-pager-link-@i @GetCurrent(i)" data-url="@(Url.Action("Load", "CmsMediaPicker"))" data-pager-mediaid="@(mediaId)" data-pager-keyword="@(keyword)" data-page="@i" data-size="5" data-container=".js-pager-container">@i</a>
    }    
    </div> 
</div>
